//
//  WFBaseSegment.m
//  谷居
//
//  Created by dllo on 16/6/22.
//  Copyright © 2016年 刘万方. All rights reserved.
//

#import "WFBaseSegment.h"

@implementation WFBaseSegment

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithItems:(NSArray *)items {
    self = [super initWithItems:items];
    if (self) {
        [self setColor];
        [self addObserver];
    }
    return self;

}
- (void)setColor {
    if (!IS_LONG) {
        self.tintColor = [UIColor colorWithRed:0.1454 green:0.0011 blue:0.9115 alpha:1.0];
        self.layer.borderColor = [UIColor colorWithRed:0.1454 green:0.0011 blue:0.9115 alpha:1.0].CGColor;
        //    _segment.segmentedControlStyle
        self.backgroundColor = [UIColor whiteColor];
    } else {
        self.tintColor = NIGHT_COLOR;
        self.layer.borderColor = NIGHT_COLOR.CGColor;
//        self.backgroundColor = [UIColor grayColor];
        }
}

- (void)addObserver {
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeToNight:) name:@"夜间模式" object:nil];
    
}
-(void)changeToNight:(NSNotification *)sender {
    if (!IS_LONG) {
        self.tintColor = NIGHT_COLOR;
        self.layer.borderColor = NIGHT_COLOR.CGColor;
//        self.backgroundColor = [UIColor grayColor];
    } else {
        self.tintColor = [UIColor colorWithRed:0.1454 green:0.0011 blue:0.9115 alpha:1.0];
        self.layer.borderColor = [UIColor colorWithRed:0.1454 green:0.0011 blue:0.9115 alpha:1.0].CGColor;
        //    _segment.segmentedControlStyle
        self.backgroundColor = [UIColor whiteColor];
    }
}
- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];

    [super dealloc];
}

@end
